
custom=$2


mcp(){
	local src=$1
	local dest=$2
	test -d $src && cp -rf $src/* $dest/


}


RED="\033[0;31m"
YELLOW="\033[1;33m"
GREEN="\033[0;32m"
NO_COLOR="\033[0m"
BOLD="\033[1m"
UNDERLINE="\033[4m"
warn_debug=true
print_debug=true
print_color=36
die() {
	echo -e "==> ${RED}${@}${NO_COLOR}"
	exit 1
}

warn() {
	if [[ "$warn_debug" = true ]]; then
		echo -e "==> ${YELLOW}${@}${NO_COLOR}"
	fi
}

good() {
	echo -e "==> ${GREEN}${*}${NO_COLOR}"
}

main(){
	project=$1
	good project=${1}
	#平台
	local platform=$(grep  TARGET_BOARD_PLATFORM device/${custom}/${project}/BoardConfig.mk  | awk -F"=" '{print$2}'| sed 's# ##g')
	#mt6735m mt6737 mt6737m
	if [ "${platform}" == "mt6735m" -o "${platform}" == "mt6737m"  -o "${platform}" == "mt6737" ];then
		platform=mt6735m
	else
		platform=mt6735
	fi
	good platform=${platform}
	
	#电池
	local battery=$(grep -w  CUSTOM_KERNEL_BATTERY device/${custom}/${project}/ProjectConfig.mk | awk -F"=" '{print$2}' | sed 's# ##g')
	good battery=${battery}

	#flash
	local flash=$(grep -w  XUNHU_PROJECT_MEMORY_TYPE  device/${custom}/${project}/ProjectConfig.mk | awk -F"=" '{print$2}' | sed 's# ##g')
	good flash=${flash}


	#gps
	local gps=$(grep -w XUNHU_GPS_CLOCK_TYPE_SUPPORT device/${custom}/${project}/ProjectConfig.mk | awk -F"=" '{print$2}' | sed 's# ##g')
	good gps=${gps}

	#gps
	local logo=$(grep -w BOOT_LOGO device/${custom}/${project}/ProjectConfig.mk | grep -v AUTO_ADD_GLOBAL_DEFINE_BY_VALUE | awk -F"=" '{print$2}' | sed 's# ##g')
	good logo=${logo}

#tp基础外设
	cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/touchpanel/*		kernel-3.18/drivers/input/touchscreen/mediatek/ 
	cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/accelerometer/*		kernel-3.18/drivers/misc/mediatek/accelerometer/
	cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/alsps/*				kernel-3.18/drivers/misc/mediatek/alsps/
	cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/magnetometer/*  	kernel-3.18/drivers/misc/mediatek/magnetometer/
	cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/lens/*  			kernel-3.18/drivers/misc/mediatek/lens/common/
	cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/lcm/*  				kernel-3.18/drivers/misc/mediatek/lcm/
	cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/imgsensor/* 		kernel-3.18/drivers/misc/mediatek/imgsensor/src/${platform}/
	cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/camera_hw/*  		kernel-3.18/drivers/misc/mediatek/imgsensor/src/${platform}/camera_hw/
#移动后删除
	rm -rf  kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/touchpanel		
	rm -rf  kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/accelerometer	
	rm -rf 	kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/alsps			
	rm -rf  kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/magnetometer  	
	rm -rf  kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/lens  			
	rm -rf  kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/lcm  			
	rm -rf  kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/imgsensor 		
	rm -rf  kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/camera_hw  		
#battery
	if [ "${battery}" == "battery" ];then
		cp -rf  kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/power/*  		kernel-3.18/drivers/misc/mediatek/include/mt-plat/mt6735/include/mach/
		rm -rv kernel-3.18/drivers/misc/mediatek/mach/mt6735/${project}/power
	else
		cp -rf kernel-3.18/drivers/misc/mediatek/mach/mt6735/common/battery/${battery}/*  	kernel-3.18/drivers/misc/mediatek/include/mt-plat/mt6735/include/mach/
	fi

#vendor
	#if [ "${platform}" == "mt6735m" ];then
	#	cp -rf vendor/mediatek/proprietary/custom/${project}/hal/* vendor/mediatek/proprietary/custom/mt6735/hal/D2
	#else
	#	cp -rf vendor/mediatek/proprietary/custom/${project}/hal/* vendor/mediatek/proprietary/custom/mt6735/hal/D1
	#fi
	cp -rf   vendor/mediatek/proprietary/custom/${project}/hal/D* vendor/mediatek/proprietary/custom/mt6735/hal
	rm -rf vendor/mediatek/proprietary/custom/${project}/hal/D*
	cp -rf vendor/mediatek/proprietary/custom/ali6735_35g_m0/hal/Android.mk vendor/mediatek/proprietary/custom/${project}/hal/
	if [ "${platform}" == "mt6750" ];then
		cp -rf vendor/mediatek/proprietary/custom/${project}/hal/* vendor/mediatek/proprietary/custom/mt6755/hal
	fi
	#rm -rf vendor/mediatek/proprietary/custom/${project}/hal
	#mv vendor/mediatek/proprietary/custom/${project}/halbase  vendor/mediatek/proprietary/custom/${project}/hal
#flash
	#test -f vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/custom_MemoryDevice.h.${flash} && cp -rf vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/custom_MemoryDevice.h.${flash}  vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/${project}/inc/custom_MemoryDevice.h

#gps
	#if [ "${gps}" == "cogps" ];then
	#	cp device/mediatek/mt6735/gps_file/co_clock/WMT_SOC.cfg  device/teksun/${project}/WMT_SOC.cfg
	#	cp device/mediatek/mt6735/gps_file/co_clock/CFG_GPS_Default.h  vendor/mediatek/proprietary/custom/${project}/cgen/cfgdefault/CFG_GPS_Default.h
	#elif [ "${gps}" == "tcxo" ];then
	#	cp device/mediatek/mt6735/gps_file/tcxo/WMT_SOC.cfg  device/teksun/${project}/WMT_SOC.cfg
	#	cp device/mediatek/mt6735/gps_file/tcxo/CFG_GPS_Default.h  vendor/mediatek/proprietary/custom/${project}/cgen/cfgdefault/CFG_GPS_Default.h
	#fi

#logo
#不做提取
	#if [ -n "${logo}" ];then
	#	mkdir -p vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/out/
	#	mkdir -p vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/out/${logo}
	#	cp -rf  vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/${logo}  vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/out/
	#	cp -rf  device/teksun/${project}/custom/logo/${logo}/*  vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/out/${logo}/
 	#fi

#make_month.h
#编译拷贝的时候动作
#echo "#define RTC_DEFAULT_MTH $(shell date +%-m)" > vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/$(XUNHU_BUILD_TARGET_PROJECT)/inc/make_month.h)
#echo "#define RTC_DEFAULT_YEA $(shell date +%Y)" >> vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/$(XUNHU_BUILD_TARGET_PROJECT)/inc/make_month.h)

#echo "#define RTC_DEFAULT_MTH $(shell date +%-m)" > kernel-3.18/drivers/misc/mediatek/rtc/make_month.h)
#echo "#define RTC_DEFAULT_YEA $(shell date +%Y)" >> kernel-3.18/drivers/misc/mediatek/rtc/make_month.h)





}



main $1 $2 $3
